<div>
    <h2><?php echo $this->link($this->U('post', 'edit'), $this->T('New Post')); ?></h2>
</div>

<div class="cl" style="height:25px;">&nbsp;</div>

<?php
if (isset($this->posts)) {
    $this->dojo()->enable()
                 //->setCdnVersion('1.3.1')
                 ->setDjConfigOption('parseOnLoad', true)
                 ->setDjConfigOption('isDebug', false)
                 ->setDjConfigOption('locale', 'zh')

                 ->registerDojoStylesheet(true)
                 ->requireModule('dijit.dijit')
                 ->requireModule('dojox.grid.DataGrid')
                 ->requireModule('dojo.data.ItemFileWriteStore')
                 ->requireModule('dojo.parser')
                 ;

    if ($this->dojo()->useCdn()) {
        $base = $this->dojo()->getCdnBase()
              . $this->dojo()->getCdnVersion();

        $this->dojo()->addStylesheet($base . '/dojox/grid/resources/Grid.css')
                     ->addStylesheet($base . '/dojox/grid/resources/tundraGrid.css')
                     ->addStylesheet($base . '/dijit/themes/tundra/tundra.css');
    } else {
        $this->dojo()->addStylesheet($this->pathJs . 'dojo/dojox/grid/resources/Grid.css')
                     ->addStylesheet($this->pathJs . 'dojo/dojox/grid/resources/tundraGrid.css')
                     ->addStylesheet($this->pathJs . 'dojo/dijit/themes/tundra/tundra.css');
    }

    $data = new Zend_Dojo_Data();
    $data->setIdentifier('postId')
         ->setLabel('My post list')
         ->addItems($this->posts);

    //var_dump($data);

    echo $this->paginationControl($this->posts, 'Sliding', array('post/paginationControl.phtml', 'admin'));
?>

    <script type="text/javascript">
        dojo.addOnLoad(function() {
            var gridLayout = [[
                {name: 'Post',              field: 'postId'},
                {name: 'Category',          field: 'postCategoryId'},
                {name: 'Url in title',      field: 'postUrlTitle',  width: "450px"},
                {name: 'Author',            field: 'postAuthorId'},
                {name: 'Data created at',   field: 'postCreatedAt', width: "150px"},
                {name: 'Delete',            field: '',              width: "50px"}
            ]];
            console.log('<?php echo $data; ?>');
            var test_store = new dojo.data.ItemFileWriteStore({data: <?php echo $data; ?>});
            gridNode.setStructure(gridLayout);
            gridNode.setStore(test_store);
        });
    </script>
    <br />
    <div id="postGrid" jsId="gridNode" dojoType="dojox.grid.DataGrid" rowsPerPage="12"></div>
<?php
}
?>